package app;

import cn.hsa.hsaf.idgenerator.properties.CommonProperties;
import cn.hsa.hsaf.idgenerator.properties.SnowFlowerProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * Created by gulx@neusoft.com on 2020/3/24.
 */
@Configuration
public class Configration {

    @Value("${worker.id}")
    Long workerId;

    @Bean
    public cn.hsa.hsaf.idgenerator.properties.CommonProperties commonProperties( CommonProperties commonProperties){
        return commonProperties;
    }

    @Bean("cn.hsa.hsaf.idgenerator.redis.HsafRedisClient")
    public cn.hsa.hsaf.idgenerator.redis.HsafRedisClient hsafRedisClient(RedisTemplate redisTemplate){
        return new cn.hsa.hsaf.idgenerator.redis.impl.RedisClientTemplateImpl(redisTemplate);
    }

    @Bean
    public SnowFlowerProperties snowFlowerProperties(SnowFlowerProperties snowFlowerProperties){
        snowFlowerProperties.h(workerId);
        return snowFlowerProperties;
    }

}
